package com.yljk.mydoctor.view;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;

import androidx.core.widget.NestedScrollView;

import com.yilijk.base.utils.ALog;

public class MyScrollView extends NestedScrollView {

    private TextView textView;

    public void setTextView(TextView textView){
        this.textView = textView;
    }



    public MyScrollView(Context context) {
        super(context);
    }

    public MyScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onScrollChanged(int X, int Y, int oldX, int oldY) {
        super.onScrollChanged(X, Y, oldX, oldY);
//        ALog.d("onScrollChanged:", "X="+X+",Y="+Y+",oldX="+oldX+",oldY="+oldY);
        if(textView!=null){
            ALog.d("onScrollChanged:", "X="+X+",Y="+Y+",oldX="+oldX+",oldY="+oldY);
            if (Y == 0){
                textView.setAlpha(0f);
            }else if (Y>0&&Y<=36){
                textView.setAlpha(0.1f);
            }else if (Y>0&&Y<=36*2){
                textView.setAlpha(0.2f);
            }else if (Y>0&&Y<=36*3){
                textView.setAlpha(0.3f);
            }else if (Y>0&&Y<=36*4){
                textView.setAlpha(0.4f);
            }else if (Y>0&&Y<=36*5){
                textView.setAlpha(0.5f);
            }else if (Y>0&&Y<=36*6){
                textView.setAlpha(0.6f);
            }else if (Y>0&&Y<=36*7){
                textView.setAlpha(0.7f);
            }else if (Y>0&&Y<=36*8){
                textView.setAlpha(0.8f);
            }else if (Y>0&&Y<=36*9){
                textView.setAlpha(0.9f);
            }else if (Y>0&&Y<=36*10){
                textView.setAlpha(1f);
            }
        }
    }
}
